package com.world.rickcloudendpoint.algorithm;

import com.world.rickcloudendpoint.algorithm.math.Vector3;

import java.util.ArrayList;

/**
 * @description: 点
 * @author: jlsong
 * @date: 2021/12/27 23:02:06
 * @version: 1.0
 */
public class GisPoint {

    //坐标
    private Vector3 coordinate;

    //父节点
    private GisPoint parent;

    //ID 连接信息
    private String[] idConnections;

    //ID
    private String id;

    //F
    private double F;

    //G
    private double G;

    //H
    private double H;

    //是否可用
    private boolean isValidate;

    //连接点
    private ArrayList<GisPoint> connections;

    //构造函数
    public GisPoint() {
        coordinate = new Vector3(0, 0, 0);
        parent = null;
        F = 0;
        G = 0;
        H = 0;
        isValidate = true;
        connections = new ArrayList<GisPoint>();
    }

    //构造函数
    public GisPoint(double x, double y, double z) {
        coordinate = new Vector3(x, y, z);
        parent = null;
        F = 0;
        G = 0;
        H = 0;
        isValidate = true;
        connections = new ArrayList<GisPoint>();
    }

    //添加连接
    public void addConnection(GisPoint point) {
        connections.add(point);
    }

    //获取F
    public double getF() {
        return getG() + getH();
    }

    //获取坐标
    public Vector3 getCoordinate() {
        return coordinate;
    }

    //设置坐标
    public void setCoordinate(Vector3 coordinate) {
        this.coordinate = coordinate;
    }

    //获取父
    public GisPoint getParent() {
        return parent;
    }

    //设置父
    public void setParent(GisPoint parent) {
        this.parent = parent;
    }

    //获取 G
    public double getG() {
        return G;
    }

    //设置G
    public void setG(double g) {
        G = g;
    }

    //获取 H
    public double getH() {
        return H;
    }

    //设置 H
    public void setH(double h) {
        H = h;
    }

    //是否可用
    public boolean isValidate() {
        return isValidate;
    }

    //设置是否可用
    public void setValidate(boolean validate) {
        isValidate = validate;
    }

    //获取连接数量
    public int connectionCount() {
        return connections.size();
    }

    //获取连接点
    public GisPoint getConnectionPoint(int i) {
        return connections.get(i);
    }

    //获取ID连接
    public String[] getIdConnections() {
        return idConnections;
    }

    //设置ID连接
    public void setIdConnections(String[] idConnections) {
        this.idConnections = idConnections;
    }

    //获取ID
    public String getId() {
        return id;
    }

    //设置ID
    public void setId(String id) {
        this.id = id;
    }

    //克隆
    @Override
    public GisPoint clone() {
        GisPoint ret = new GisPoint();
        ret.setCoordinate(getCoordinate());
        ret.setValidate(true);
        ret.setParent(null);
        ret.setId(getId());
        ret.idConnections = getIdConnections();
        return ret;
    }


}
